
//
//  AXFMarketClick.swift
//  SpuerYangAngWang
//
//  Created by 杨茂盛 on 2016/12/24.
//  Copyright © 2016年 杨茂盛. All rights reserved.
//

import UIKit

class AXFMarketClickView: UIControl {
    //减号按钮
    @IBOutlet weak var descretBtn: UIButton!
    //加号按钮
    @IBOutlet weak var crementBtn: UIButton!
    //数量按钮
    @IBOutlet weak var countLabel: UILabel!

    var rightModel = [AXFRightModel]()
    
    class func ClickGoodsView() ->(AXFMarketClickView){
        return Bundle.main.loadNibNamed("AXFMarketClickView", owner: self, options: nil)?.first as! (UIView) as! (AXFMarketClickView)
    }
    
    //标记点击了左边还是右边
    var isLeftOrRight = false
    //记录按钮的点击次数
    var str:String?
    var idex:Int = 0 {
        didSet{
            
            descretBtn.isHidden = idex == 0
            
            countLabel.isHidden = idex == 0
            
            countLabel.text = "\(idex)"
        }
    }
    
    //加号按钮的点击事件
    @IBAction func crementBtn(_ sender: Any) {
        idex += 1
        //如果是右边点击,就让标记为YES
        self.isLeftOrRight = true
        //发送点击事件
        self.sendActions(for: .valueChanged)
    }
    
    //减号按钮的点击事件
    @IBAction func descretBtn(_ sender: Any) {
        idex -= 1
        //如果是左边点击,就让标记为NO
        self.isLeftOrRight = false
        self.sendActions(for: .valueChanged)
    }
}
